package com.zpark.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author xiaoyu
 * @version 1.0 2022/9/13
 */
@Controller
@RequestMapping("/thy")
public class ThymeleafController {
    @GetMapping("/text")
    public ModelAndView text() {
        //创建视图解析器
        ModelAndView mv = new ModelAndView();
        //设置视图名字
        mv.setViewName("text");
        //绑定数据
        mv.addObject("dc", "Hello Thymeleaf");

        return mv;
    }

    @GetMapping("/utext")
    public ModelAndView uText() {
        //创建视图解析器
        ModelAndView mv = new ModelAndView();
        //设置视图名字
        mv.setViewName("utext");
        //绑定数据
        mv.addObject("content", "<s>这是utext属性</s>");
        return mv;
    }
    @GetMapping("/value")
    public ModelAndView value() {
        //创建视图解析器
        ModelAndView mv = new ModelAndView();
        //设置视图名字
        mv.setViewName("value");
        //绑定数据
        mv.addObject("username", "大锤");
        return mv;
    }
    @GetMapping("/if")
    public ModelAndView myIf() {
        //创建视图解析器
        ModelAndView mv = new ModelAndView();
        //设置视图名字
        mv.setViewName("if-unless-switch-case");
        //绑定数据
        mv.addObject("bool", "F");
        return mv;
    }

    @GetMapping("/css")
    public ModelAndView css() {
        //创建视图解析器
        ModelAndView mv = new ModelAndView();
        //设置视图名字
        mv.setViewName("demo03");
        //绑定数据
        mv.addObject("bool", "F");
        return mv;
    }

    @GetMapping("/par")
    public void myPar(String name, Integer age) {
        System.out.println(name);
        System.out.println(age);
    }
}
